package edu.itla.medifacil.helpers;

import java.util.HashMap;
import java.util.Map;

import edu.itla.medifacil.persistence.entities.People;
import edu.itla.medifacil.persistence.entities.PersonAttributesValue;

public class Utilities {

	@SuppressWarnings("rawtypes")
	public static Map<String, String> parametersArrayToMap( Map paramenters ){
		Map<String, String> map = new HashMap<String, String>();
		for( Object key : paramenters.keySet() ){
			String [] value = (String [])paramenters.get(key.toString());
			map.put( key.toString(), value[0] );
		}
		
		return map;
	}
	
	
	public static Map<Integer, String> extractPersonAttributes( People person ){
		Map<Integer, String> personAttributes = new HashMap<Integer, String>();
		for( PersonAttributesValue patientAttribute : person.getPersonAttributesValues() ){
			personAttributes.put( patientAttribute.getAttribute().getId(), patientAttribute.getValue());
		}
		
		return personAttributes;
	}
}